package com.itheima.demo;

import java.util.Scanner;

public class AllTest {

    public static void main(String[] args) {

        //需求：完成健康计算器
        //1.接收用户输入的身高、体重、年龄、性别
        //2.根据用户输入信息，计算BMI
        //3.根据用户输入信息，计算BMR
        //4.

        //1.接收用户输入的身高、体重、年龄、性别
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入您的身高：");
        double height = sc.nextDouble();
        System.out.println("请输入您的体重：");
        double weight = sc.nextDouble();
        System.out.println("请输入您的年龄：");
        int age = sc.nextInt();
        System.out.println("请输入您的性别：");
        String sex = sc.next();

        double bmi = getBMI(height, weight);
        System.out.println("您的BMI值为：" + bmi);

        double bmr = getBMR(age, sex, height, weight);
        System.out.println("您的BMR值为：" + bmr);

    }

    //2.根据用户输入信息，计算BMI
    public static double getBMI(double height, double weight) {
        return weight / (height * height);
    }

    //3.根据用户输入信息，计算BMR
    public static double getBMR(int age, String sex, double height, double weight) {
        double bmr = 0;
        if ("男".equals(sex)) {
            bmr = 88.362 + 13.397 * weight + 4.799 * height - 5.677 * age;
        } else if ("女".equals(sex)) {
            bmr = 447.593 + 9.247 * weight + 3.098 * height - 4.330 * age;
        }
        return bmr;
    }

}
